//
//  ReportCardITotalView.m
//  jzyParents
//
//  Created by 任辰东 on 2022/8/22.
//

#import "ReportCardITotalView.h"
#import "NSString+Attributed.h"

@interface ReportCardITotalView ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UIView *markView;
@property (nonatomic, strong) UILabel *markLabel;
@property (nonatomic, strong) UILabel *scoreMarkLabel;
@property (nonatomic, strong) UILabel *scoreLabel;

@end

@implementation ReportCardITotalView

-(void)configViewWithModel:(Kaoshi_zong_score *)model
{
    self.scoreLabel.text = IsEmpty(model.total_score) ? @"暂无":model.total_score;
}

-(void)setupViews
{
    [self addBottomLineWithEdge:UIEdgeInsetsMake(0, 15, 0, 15)];
    [self addSubview:self.titleLabel];
    [self addSubview:self.line];
    [self addSubview:self.markView];
    [self addSubview:self.markLabel];
    [self addSubview:self.scoreMarkLabel];
    [self addSubview:self.scoreLabel];
    
    self.scoreMarkLabel.text = @"总分";
    
    NSString *className = IsEmpty([GVUserDefaults standardUserDefaults].class_name) ? @"暂无班级":[GVUserDefaults standardUserDefaults].class_name;
    self.titleLabel.text = [NSString stringWithFormat:@"%@   %@",[GVUserDefaults standardUserDefaults].student_name,className];
    self.scoreMarkLabel.text = @"总分";
}

-(void)setupLayout
{
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self).offset(15);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
    }];
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.titleLabel.mas_bottom).offset(15);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.height.mas_equalTo(kOnePixel*2);
    }];
    
    [self.markView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.line).offset(20);
        make.left.equalTo(self).offset(15);
        make.height.mas_equalTo(13);
        make.width.mas_equalTo(4);
        
    }];
    
    [self.markLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.equalTo(self.markView);
        make.left.equalTo(self.markView.mas_right).offset(8);
    }];
    
    CGFloat width = (kScreenWidth - 15 *2) /5.0;
    [self.scoreMarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.markView.mas_bottom).offset(15);
        make.left.equalTo(self).offset(15);
        make.width.mas_equalTo(width);
        make.bottom.equalTo(self).offset(-8);
        make.bottom.equalTo(self).offset(-15);
    }];
    
    [self.scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.scoreMarkLabel.mas_right).offset(10);
        make.top.equalTo(self.markView.mas_bottom).offset(15);
        make.width.mas_equalTo(width);
    }];
    
}

#pragma mark -- lazyload

-(UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.textColor = UIColorFromHex(0x000000);
        _titleLabel.font = UIFontSize(15);
    }
    return _titleLabel;
}

-(UIView *)line
{
    if (!_line) {
        _line = [UIView new];
        _line.backgroundColor = UIColorFromHex(kColorBG);
    }
    return _line;
}

-(UIView *)markView
{
    if (!_markView) {
        _markView = [UIView new];
        _markView.backgroundColor = UIColorFromHex(kColorMain);
    }
    return _markView;
}

-(UILabel *)markLabel
{
    if (!_markLabel) {
        _markLabel = [UILabel new];
        _markLabel.text = @"成绩得分";
        _markLabel.textColor = UIColorFromHex(0x000000);
        _markLabel.font = UIFontSize(14);
    }
    return _markLabel;
}

-(UILabel *)scoreMarkLabel
{
    if (!_scoreMarkLabel) {
        _scoreMarkLabel = [UILabel new];
        _scoreMarkLabel.textColor = UIColorFromHex(0x666666);
        _scoreMarkLabel.font = UIFontSize(14);
    }
    return _scoreMarkLabel;
}

-(UILabel *)scoreLabel
{
    if (!_scoreLabel) {
        _scoreLabel = [UILabel new];
        _scoreLabel.textColor = UIColorFromHex(0x000000);
        _scoreLabel.font = UIFontSize(14);
        _scoreLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _scoreLabel;
}

@end
